extends Area2D

enum Items {health, ammo}

var icon_texture = [
	preload("res://assets/wrench.png"),
	preload("res://assets/heavy-bullets.png")
]

export (Items) var type = Items.health
export (Vector2) var amount = Vector2(20, 30)


func _ready():
	$Box/Icon.texture = icon_texture[type]

func _on_Pickup_body_entered(body):
	match type:
		Items.health:
			if body.has_method("heal"):
				body.heal(int(rand_range(amount.x, amount.y)))
		Items.ammo:
			if body.has_method("add_ammo"):
				body.add_ammo(int(rand_range(amount.x, amount.y)))
	queue_free()
